<?php

class Kd_Html_Form_Textbox extends Kd_Html_Form_Element {

    public function __construct() {
        parent::__construct();
        $this->templateName = 'form/textbox';
        $this->addClass('input', 'textbox');
    }

    public function getBackgroundText() {
        return $this->getAttribute('backgroundText');
    }

    public function setBackgroundText($value) {
        return $this->setAttribute('backgroundText', $value);
    }

    protected function renderReadonly() {
        return '<span class="readonly">' . $this->getValue() . '</span>';
    }

    protected function renderEditable() {
        if (!$this->getEnabled()) {
            $this->addClass('disabled');
        }
        $this->setAttribute('type', 'text');
        if($this->getId()){
        	$this->setAttribute('id', $this->getId());
        }
        if($this->getName()){
        	$this->setAttribute('name', $this->getName());
        }
        if($this->getValue()){
        	$this->setAttribute('value', $this->getValue());
        }
        if (!$this->getEnabled()) {
            $this->setAttribute('disabled', 'disabled');
        }
        return '<input ' . $this->getAttributeHtml() . '/>';
    }

}